<template>
	<clipBar></clipBar>
	<view class="mine_page">
		<button class="button" @tap="canDrawOverlaysFn">判断悬浮窗权限</button>
		<button class="button" @tap="wakeupAndUnlockFn">点亮解锁手机屏幕</button>
		<button class="button" @tap="setTopAppFn">应用切换到前台</button>
		<button class="button" @tap="testCheckCalendar">检查日历</button>
		<button class="button" @tap="testAddCalendar">新加日历</button>
		<button class="button" @tap="testUpdateCalendar">修改日历</button>
		<button class="button" @tap="testDelCalendar">删除日历</button>
		<button class="button" @tap="testQueryCalendar">查询日历</button>
	</view>
	<clipTabbar curIndex="1"></clipTabbar>
</template>

<script setup>
	import {
		canDrawOverlays,
		setTopApp,
		wakeupAndUnlock
	} from "@/utils/remindFn.js"
	import {
		checkCalendar,
		addCalendar,
		updateCalendar,
		deleteCalendar,
		queryCalendar
	} from "@/utils/calendar";

	function canDrawOverlaysFn() {
		canDrawOverlays()
	}
	//将自身应用从后台切换到前台；如果应用进程被杀掉了，则命令无效。
	function setTopAppFn() {
		//点击按钮后，迅速将App手动置于后台即可
		setTimeout(() => {
			setTopApp()
		}, 3000);
	}
	//点击按钮后，迅速锁屏即可
	function wakeupAndUnlockFn() {
		setTimeout(() => {
			console.log('亮屏了')
			wakeupAndUnlock()
		}, 5000);
	}

	function testAddCalendar() {
		let data = {
			title: "马上吃饭",
			desc: "吃好吃的",
			location: "南信院二食堂",
			start: new Date().getTime() + 300000,
			end: new Date().getTime() + 1010000,
			advanceTime: 0,
			rule: null,
			eventId: new Date().getTime() + "_e"
		}
		console.log(new Date().getTime() + "_e", JSON.stringify(data))
		addCalendar(data)
	}

	function testCheckCalendar() {
		checkCalendar()
	}

	function testDelCalendar() {
		deleteCalendar("1720848672781_e")
	}

	function testUpdateCalendar() {
		let data = {
			"title": "马上不吃饭",
			"desc": "吃好吃的",
			"location": "南信院二食堂",
			"start": 1720848972781,
			"end": 1720849682781,
			"advanceTime": 0,
			"rule": null,
			"eventId": "1720848672781_e"
		}
		updateCalendar(data)
	}

	function testQueryCalendar() {
		queryCalendar("1720848672781_e")
	}
</script>

<style>
</style>